﻿// © Benn Eichhorn 2010
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algobox.Feeds.Finance.Bats.PitchClient.Messages
{
    /// <summary>
    /// Singleton Error message
    /// </summary>
    public class Error : IMessage
    {
        #region Singleton

        private Error() { }

        private static Error m_instance = new Error();

        /// <summary>
        /// Get's the singleton instance of the Error class
        /// </summary>
        /// <returns>Current Error</returns>
        public static Error GetInstance() { return m_instance; }

        /// <summary>
        /// Get's the singleton instance of the Error class
        /// </summary>
        /// <param name="description">Description of the error</param>
        /// <returns>Current Error</returns>
        public static Error GetInstance(string description)
        {
            m_instance.Description = description;
            m_instance.OriginalMessage = String.Empty;
            return m_instance;
        }

        /// <summary>
        /// Get's the singleton instance of the Error class
        /// </summary>
        /// <param name="description">Description of the error</param>
        /// <param name="message">A copy of the incoming message string from Chi-X</param>
        /// <returns>Current Error</returns>
        public static Error GetInstance(string description, ref string message)
        {
            m_instance.Description = description;
            m_instance.OriginalMessage = message;
            return m_instance;
        }

        #endregion

        public char MessageType { get { return 'E'; } }

        public string Description;
        public string OriginalMessage;

        public override string ToString()
        {
            return "IMessage->Error:Description=" + Description;
        }


    }
}
